<script type="text/javascript">
		// Activo el Mejorador de SELECT
    jQuery(".chzn-select").chosen({
      width: "95%"
    });
	
	jQuery(document).ready(function(){ 
		jQuery( "#tabs" ).tabs();
	});
</script>
<?php
	if(empty($this->data['Person']['foto'])){
		if($this->data['Person']['sex_id'] == 1){ // Si es Masculino
			$imagen_paciente = "/images/profile_m.png";
		}else{
			$imagen_paciente = "/images/profile_w.png";
		}
	} else {
		$imagen_paciente = $this->webroot.'uploads/'.$this->data['Person']['foto'];
	}
?>
<?php echo $this->Form->create('Person',array('enctype'=>"multipart/form-data"));?>
<div id="tabs">
	<ul>
		<li><a href="#tabs-1">Datos del Paciente</a></li>
		<li><a href="#tabs-2">Foto</a></li>
	</ul>
	<div id="tabs-1">

		<div id="nombre_perfil">
			<img src="<?php echo $imagen_paciente?>" style='height:40px;margin:5px;float:left;margin-right:20px;'>
			<h2 style="padding-top: 10px;"><?php echo $this->data['Person']['full_name'] ?></h2>	
		</div>
		<br/>
		<div class="people form">
		<?php echo $this->Form->input('id'); ?>
		<?php echo $this->Form->input('user_id',array('type'=>'hidden')); ?>

		  <table cellpadding="0" cellspacing="10">
			<tr> 
			  <td width="33%"><?php echo $this->Form->input('name',array( 'label' => '1er. Nombre')); ?></td>
			  <td width="33%"><?php echo $this->Form->input('name2',array( 'label' => '2do. Nombre')); ?></td>
			  <td width="34%"><?php echo $this->Form->input('name3',array( 'label' => 'Otros Nombres')); ?></td>
			</tr>
			<tr> 
			  <td><?php echo $this->Form->input('lastname',array( 'label' => '1er. Apellido'));?></td>
			  <td><?php echo $this->Form->input('lastname2',array( 'label' => 'Otros Apellidos'));?></td>
			  <td><?php echo $this->Form->input('lastname3',array( 'label' => 'Apellido Materno')); ?></td>
			</tr>
			<tr> 
			  <td><?php echo $this->Form->input('gender_id',array( 'label' => 'Género','empty' => '--- Seleccione uno ---'));?></td>
			  <td><?php echo $this->Form->input('sex_id',array( 'label' => 'Sexo', 'empty' => '--- Seleccione uno ---')); ?></td>
			  <td><?php echo $this->Form->input('fecha_nacimiento',array( 'label' => 'Fecha de Nacimiento', 'empty' => '---'
											, 'dateFormat' => 'DMY'
											, 'minYear' => date('Y') - 100
											, 'maxYear' => date('Y') ));?></td>
			</tr>
			<tr> 
			  <td><?php echo $this->Form->input('typodocument_id',array( 'label' => 'Tipo de Documento','empty' => '--- Seleccione uno ---'));?></td>
			  <td><?php echo $this->Form->input('nro_documento',array( 'label' => 'Nro. de Documento')); ?></td>
			  <td><?php echo $this->Form->input('gruposanguineo_id',array( 'label' => 'Grupo Sanguíneo','empty' => '--- Seleccione uno ---')); ?></td>
			</tr>
			<tr> 
			  <td><?php echo $this->Form->input('email'); ?></td>
			  <td><?php echo $this->Form->input('telefono',array( 'label' => 'Teléfono')); ?></td>
			  <td>&nbsp;</td>
			</tr>

			<tr> 
			  <td><?php echo $this->Form->input('direccion',array( 'label' => 'Domicilio')); ?></td>
			  <td><?php echo $this->Form->input('localidad',array( 'label' => 'Localidad')); ?></td>
			  <td><?php echo $this->Form->input('provincia',array( 'label' => 'Provincia / Region')); ?></td>
			</tr>



			<?php foreach($os as $clave=>$valor){ ?>
				<tr> 
				  <td><?php 
						echo $this->Form->input('OS.'.$clave.'.id', array(
												'class' 			=> 'chzn-select', 
												'options' 			=> $insurances, 
												'selected' 			=> $valor['id'], 
												'label' 			=> 'Financiador '.($clave+1), 
												'empty'				=> __('Ninguna',true), 
												'style' 			=> 'width:350px;'
												)
											);		
						?>
				  </td>
				  <td>
				<label for='plan_<?php echo $clave;?>'>Plan</label> 
				<input type='text' name='data[OS][<?php echo $clave;?>][plan]' id='plan_<?php echo $clave;?>'  value='<?php echo $valor['plan'];?>'>
				<?php //echo $this->Form->input('OS.'.$clave.'.plan'    ,array('value' => $valor['plan']    , 'label' => 'Plan'        ) ); ?>  
			  </td>
				  <td><?php echo $this->Form->input('OS.'.$clave.'.afiliado',array('value' => $valor['afiliado'], 'label' => 'Nro.Afiliado') ); ?>  </td>
				</tr>
			<?php } // end foreacu?>

			<tr> 
			  <td colspan='3'><h2 style='font-size:16px;'>Profesional Derivante</h2></td>
			</tr>
			<tr> 
			  <td><?php echo $this->Form->input('profesional_derivante',array( 'label' => 'Nombre del Profesional')); ?></td>
			  <td><?php echo $this->Form->input('especialidad',array( 'label' => 'Especialidad')); ?></td>
			  <td><?php echo $this->Form->input('telefono_contacto',array( 'label' => 'Teléfono de Contacto')); ?></td>
			</tr>
		  </table>
		</div>
	</div>
	<div id="tabs-2">
		<table style='width:100%'>
			<tr>
				<td><b>Foto Actual</b></td>
				<td>
					<table style='width:100&;'>
						<tr>	
							<td><img src="<?php echo $imagen_paciente?>" style='height:40px;margin:5px;'></td>
							<td><input type='checkbox' name='eliminar_foto' style='float:left;'>Eliminar la foto</td>
						</tr>
					</table>
				</td>
			</tr>
				<td><b>Elegir Foto:</b> </td>
				<td>
					<input type='file' name='foto' id='foto' style='width:400px;'>
				</td>
			</tr>
		</table>
		<input type='hidden' name='foto_original' id='foto_original' value='<?php echo $this->data['Person']['foto'];?>'>
	</div>

	
	<?php if ($this->data['Person']['stateperson_id']==1){ ?> 
		<center>
		<?php echo $this->Form->end(__('Modificar', true)); ?>
		</center>
	<?php } //endif ?>    
	
</div>

	
	
</div>

<script>
  jQuery(function() {

    <?php foreach($os as $clave=>$valor){ ?>
      jQuery("#plan_<?php echo $clave;?>").autocomplete("/ajax/obtiene_planes_os/", {
        width: 260,
        selectFirst: true
      });
   <?php } // end foreach?>

  })
</script>

